package com.peaksport.pkms.basedata.master.controller;

import javax.ws.rs.core.MediaType;

import org.apache.servicecomb.provider.rest.common.RestSchema;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.peaksport.framework.base.controller.BaseController;
import com.peaksport.framework.extend.redis.annotation.PKCacheable;
import com.peaksport.framework.extend.redis.venum.ExpireTimeType;
import com.peaksport.pkms.permit.entity.UserEntity;

@RestSchema(schemaId="pkms-basedata-org")
@RequestMapping(value="org",produces=MediaType.APPLICATION_JSON)
public class OrgImpl extends BaseController {
	

	

	
	
	@GetMapping("/test")
	public String getOrgByRelation() {
		/*redisTemplate.opsForValue().set("ccc", "bbb");	
		redisTemplate.opsForValue().set("ddd", "郭锦彬");
		redisTemplate.opsForHash().put("myhash", "a1", "郭锦彬1");
		redisTemplate.opsForHash().put("myhash", "a2", "匹克");
		*/
		//System.out.println(redisTemplate.opsForValue().get("bbb"));
	//	prefix_system = myProps.getMapProps().get("peak.redis.prefix.system");
		UserEntity u = new UserEntity();
		u.setName("郭锦彬1");
		pkRedisTemplate.setObject("session_guo", u);
		return  pkRedisTemplate.getString("ccc") + pkRedisTemplate.getFullKey("cc");
	}
	
	@GetMapping("/name")
	@PKCacheable(expireTimeType=ExpireTimeType.expireTime_5min)
	public String getName() {
		UserEntity u = (UserEntity) pkRedisTemplate.getObject("session_guo");
		return u.getName();
		
	}
	@GetMapping(value = "/user/{name}",produces = "text/html;charset=UTF-8")
	@PKCacheable(expireTimeType=ExpireTimeType.expireTime_5min)
	public UserEntity getUser(@PathVariable("name") String name) {
		UserEntity u = new UserEntity();
		u.setName(name);
		return u;
		
	}
	
}
